home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Libris Britannia 4
/
science library(b).zip
/
science library(b)
/
PROGRAMM
/
DB_CLIPP
/
2510.ZIP
/
TRSOURCE.EXE
/
POKESTR.ASM
< prev
next >
Wrap
Assembly Source File
|
1990-10-22
|
3KB
|
96 lines
; POKESTR.ASM
;
; by Ralph Davis
; modified by Leonard Zerman
;
; Placed in the public domain by Tom Rettig Associates, 10/22/1990.
;
PUBLIC POKESTR
INCLUDE EXTENDA.MAC
EXTRN _TR_POKE_PARMS:FAR
DGROUP GROUP _DATA
;*****************************************************
_DATA SEGMENT WORD PUBLIC 'DATA'
;
; Saves input segment and offset
;
SEG_ADDR DW ?
OFF_ADDR DW ?
;
_DATA ENDS
;*****************************************************
;*****************************************************
POKESTR_TEXT SEGMENT BYTE PUBLIC 'CODE'
ASSUME CS:POKESTR_TEXT, DS:_DATA
;-----------------------------------------------------
;
; POKESTR(segment, offset, string)
;
; segment = SPACE(4) && hexadecimal string
; offset = number < 65536 or hexadecimal string
; string = <expC>
;
; Returns: .F. if less than three parameters passed
; .T. otherwise
;
; NOTE: This function will let you overwrite anything.
;
;--------------
POKESTR PROC FAR
PUSH BP
MOV BP,SP
PUSH DS
PUSH ES
PUSH DX
PUSH SI
PUSH DI
CALL _TR_POKE_PARMS ; returns segment in DX,
; returns offset in AX
JL POKESTR_ERR ; Sign flag set means less than 2 parms
PUSH DS ; Save caller's DS
MOV BX,_DATA ; Point DS to our data segment
MOV DS,BX
MOV SEG_ADDR,DX
MOV OFF_ADDR,AX
POP DS ; Restore caller's DS
GET_CHAR 3 ; get source string
PUSH DX ; save segment of source string
MOV DX,_DATA ; Point to our data segment
MOV DS,DX
MOV SI,AX
MOV DI,OFF_ADDR ; retrieve offset
MOV DX,SEG_ADDR ; retrieve segment
MOV ES,DX ; and place in ES
POP DX ; get segment of source string
MOV DS,DX ; and place it in DS
POKE_STR_GETSTR:
LODSB ; pick up byte from source string
OR AL,AL ; is it NULL character?
MOV BX,1 ; return .T. for successful completion
STOSB ; no, so put it into destination
JZ SHORT POKESTR_EXIT ; yes, so we're done
JMP SHORT POKE_STR_GETSTR
POKESTR_ERR:
MOV BX,0 ; return .F. for error
POKESTR_EXIT:
POP DI
POP SI
POP DX
POP ES
POP DS
POP BP
RET_LOGICAL BX ; Return .T. or .F. to caller
RET
POKESTR ENDP
;------------------------------------------------
POKESTR_TEXT ENDS
;************************************************
END